<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link href="https://www.sunyuchao.com/static/layui/css/layui.css"  rel="stylesheet">

</head>
<body>
<form class="layui-form" style="padding-right: 60px;margin-top: 50px;" action="">

    <div class="layui-form-item">
        <label class="layui-form-label">反馈类型</label>
        <div class="layui-input-block">
            <input type="radio" name="type" value="1" title="功能建议">
            <input type="radio" name="type" value="2" title="bug反馈" checked>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">标题</label>
        <div class="layui-input-block">
            <input type="text" class="layui-input" name="title" required lay-verify="required" placeholder="请输入标题">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">具体内容</label>
        <div class="layui-input-block">
            <textarea class="layui-textarea" name="content" required lay-verify="required" placeholder="请输入具体内容"></textarea>
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn layui-btn-normal" lay-submit lay-filter="go">立即提交</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
</form>


    <script src="https://www.sunyuchao.com/static/layui/layui.js" ></script>
    <script>
        layui.use(['form',"layer"],function () {
            var form=layui.form,
                layer=layui.layer,
                $=layui.jquery;

            form.on('submit(go)',function (data) {
                $.ajax({
                    url:"/feedback/save",
                    type:"POST",
                    data:data.field,
                    success:function (e) {
                        if(e.success){
                            layer.msg("感谢您的反馈");
                            setTimeout(function () {
                                var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                                parent.layer.close(index); //再执行关闭
                            },2000)
                        }else{
                            alert(e.message)
                        }
                    },dataType:"json"
                });
                return false;
            });
        });
    </script>
</body>
</html>